package com.rpay.service.trade.impl;

import com.rpay.dao.trade.TradeCacheDAO;
import com.rpay.model.trade.TradeCacheDO;
import com.rpay.service.trade.ITradeCacheService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class TradeCacheServiceImpl implements ITradeCacheService {
    @Autowired
    private TradeCacheDAO tradeCacheDAO;

    @Override
    public TradeCacheDO findOne() {
        return tradeCacheDAO.findOne();
    }

    @Override
    public int save(TradeCacheDO tradeCacheDO) {
        TradeCacheDO tradeCache = tradeCacheDAO.findOne();
        if (tradeCache != null) {
            return tradeCacheDAO.update(tradeCacheDO);
        } else {
            return tradeCacheDAO.insert(tradeCacheDO);
        }
    }
}
